const RandomStringUtils = require('./index');

console.log('=== Random String Utils 测试 ===\n');

// 测试基本功能
try {
    console.log('1. 生成默认长度(16位)的随机字符串:');
    console.log(RandomStringUtils.generateRandomString());
    
    console.log('\n2. 生成8位随机字符串:');
    console.log(RandomStringUtils.generateRandomString(8));
    
    console.log('\n3. 生成32位随机字符串:');
    console.log(RandomStringUtils.generateRandomString(32));
    
    console.log('\n4. 生成不含特殊符号的随机字符串:');
    console.log(RandomStringUtils.generateRandomString(12, { includeSpecialChars: false }));
    
    console.log('\n5. 只包含大写字母和数字的随机字符串:');
    console.log(RandomStringUtils.generateRandomString(10, { 
        includeLowercase: false, 
        includeSpecialChars: false 
    }));
    
    console.log('\n6. 自定义特殊字符集:');
    console.log(RandomStringUtils.generateRandomString(12, { 
        customSpecialChars: '+-*/' 
    }));
    
    console.log('\n7. 生成只包含字母的字符串:');
    console.log(RandomStringUtils.generateAlphabeticString(10));
    
    console.log('\n8. 生成只包含数字的字符串:');
    console.log(RandomStringUtils.generateNumericString(8));
    
    console.log('\n9. 生成字母数字混合字符串:');
    console.log(RandomStringUtils.generateAlphanumericString(12));
    
    console.log('\n10. 生成强密钥:');
    console.log(RandomStringUtils.generateStrongKey(20));
    
    console.log('\n11. 测试字符串打乱功能:');
    const original = 'abcdefghij';
    const shuffled = RandomStringUtils.shuffleString(original);
    console.log('原始:', original);
    console.log('打乱后:', shuffled);
    
    // 测试错误处理
    console.log('\n12. 测试错误处理:');
    try {
        RandomStringUtils.generateRandomString(5); // 长度过短
    } catch (error) {
        console.log('长度过短错误:', error.message);
    }
    
    try {
        RandomStringUtils.generateRandomString(200); // 长度过长
    } catch (error) {
        console.log('长度过长错误:', error.message);
    }
    
    try {
        RandomStringUtils.generateRandomString(10, { 
            includeUppercase: false,
            includeLowercase: false,
            includeNumbers: false,
            includeSpecialChars: false
        }); // 没有选择任何字符类型
    } catch (error) {
        console.log('无字符类型错误:', error.message);
    }
    
    console.log('\n=== 测试完成 ===');
    
} catch (error) {
    console.error('测试过程中发生错误:', error);
    process.exit(1);
}